package com.rk.jvm;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadLocalOOM {
    public static final Integer SIZE = 500;
    static ThreadPoolExecutor executor =
            new ThreadPoolExecutor(5, 5, 1,
                    TimeUnit.MINUTES, new LinkedBlockingDeque<>());

    static class LocalVariable {//总共有5M
        private byte[] locla = new byte[1024 * 1024 * 5];
    }

    final static ThreadLocal<LocalVariable> local = new ThreadLocal<>();

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < SIZE; i++) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    local.set(new LocalVariable());
                }
            });
            Thread.sleep(1000L);
        }
    }


}
